package com.fox0g.filter;
import org.springframework.stereotype.Service;

//限幅滤波法
@Service
public class ClampingFilter {
    //整数
//    private int lowerBound;
//    private int upperBound;
//
//    public ClampingFilter(int lowerBound, int upperBound) {
//        this.lowerBound = lowerBound;
//        this.upperBound = upperBound;
//    }
//
//    public int filter(int value) {
//        // 将输入值限制在上下限范围内
//        return Math.max(lowerBound, Math.min(upperBound, value));
//    }

    //double
    private double lowerBound;
    private double upperBound;

    public double getLowerBound() {
        return lowerBound;
    }

    public void setLowerBound(double lowerBound) {
        this.lowerBound = lowerBound;
    }

    public double getUpperBound() {
        return upperBound;
    }

    public void setUpperBound(double upperBound) {
        this.upperBound = upperBound;
    }

    public double filter(double value) {
        // 将输入值限制在上下限范围内
        return Math.max(lowerBound, Math.min(upperBound, value));
    }
}